/*
 *  timer.cpp
 *  
 *	Version 1.0
 *  Created by <person> on <date>.
 *  Copyright 2010 Michigan Technological University. All rights reserved.
 *
 */
#include "timer.h"

Timer::Timer()
{
	startTicks = 0;
	pausedTicks = 0;
	started = false;
	paused = false;
}
Timer::~Timer()
{
}
void Timer::start()
{
	started = true;
	paused = false;
	startTicks = SDL_GetTicks();
}
void Timer::stop()
{
	started = false;
	paused = false;
}
int Timer::getTicks()
{
	if(started)
	{
		if(paused)
			return pausedTicks;
		else
			return (SDL_GetTicks() - startTicks);
	}
	return 0;
}
void Timer::pause()
{
	if(started && !paused)
	{
		paused = true;
		pausedTicks = SDL_GetTicks() - startTicks;
	}
}
void Timer::resume()
{
	if(paused)
	{
		paused = false;
		startTicks = SDL_GetTicks() - pausedTicks;
		pausedTicks = 0;
	}
}
